13. Attitude Controller

Attitude Controller

Hope you had fun with the Hover Controller and made some great progress with it. Now, let’s make this more challenging by adding the rest of the independent degrees of freedom:

  • Roll (rotation about X-axis) - causing a simultaneous translation in the Y
  • Pitch (rotation about Y-axis) - causing a simultaneous translation in the X
  • Yaw (rotation about Z-axis)

An attitude_controller in essence controls the attitude, meaning the roll, pitch, and yaw angles of the quadrotor.

A PID based Attitude Controller runs three independent instances of the PID controller class for controlling the roll, pitch, and yaw angles respectively.

Individual error values are calculated from the differences between the desired and current angle values of the quadrotor. The controller then tries to minimize this error by adjusting (controlling) the total torque along the x, y, and z axes of the quadrotor.

An example implementation of the attitude_controller_node is provided in the quad_controller package that utilizes the PID controller class that you have implemented.

To test this Attitude Controller, you need to follow similar steps as before and make sure that your are starting the steps over for each controller type and that you do not have more than one controller running at a time:

  • Fire up roscore:
$ roscore
  • Launch the simulator: Once again, refer to the "Using the Simulator" section of the lab README file for platform-specific instructions for launching the simulator.

  • Run the attitude_controller_node:

$ roslaunch quad_controller attitude_controller.launch

Once again, you may observe that there is no change in the quadrotor’s behavior, even though the attitude_controller_node is running.

This is because the default target roll, pitch, and yaw are set to zero. Just like the Hover Controller, you must use dynamic_reconfigure to set target values and tune the PID controller for each of the three degrees of freedom roll, pitch, and yaw respectively.

You'll also need to write down these PID parameters, as mentioned previously, as you'll be using them in your positional controller.

Note: ZN and Twiddle Tuner nodes only work with the Hover Controller, they will not function correctly with the Attitude Controller.